<!DOCTYPE HTML>
<html lang="en-US" >
    
    <head>
        
        <meta charset="UTF-8">
        <title>ZeroMQ | AKKA 2.3.6 Scala 文档</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 1.0.3">
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    
    
    
    <link rel="next" href="../chapter5/09_camel.html" />
    
    
    <link rel="prev" href="../chapter5/07_using_udp.html" />
    

        
    </head>
    <body>
        
        
<link rel="stylesheet" href="../gitbook/style.css">


        
    <div class="book"  data-level="5.8" data-basepath=".." data-revision="1442802141200">
    

<div class="book-summary">
    <div class="book-search">
        <input type="text" placeholder="Type to search" class="form-control" />
    </div>
    <ul class="summary">
        
    	
    	
    	

        

        
    
        
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                        <i class="fa fa-check"></i>
                        
                         Introduction
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="1" data-path="chapter1/introduction.html">
            
                
                    <a href="../chapter1/introduction.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                         引言
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="1.1" data-path="chapter1/01_what_is_akka.html">
            
                
                    <a href="../chapter1/01_what_is_akka.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                         Akka是什么?
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="1.2" data-path="chapter1/02_why_akka.html">
            
                
                    <a href="../chapter1/02_why_akka.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                         为什么使用Akka?
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="1.3" data-path="chapter1/03_getting_started.html">
            
                
                    <a href="../chapter1/03_getting_started.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                         入门
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="1.4" data-path="chapter1/04_the_obligatory_hello_world.html">
            
                
                    <a href="../chapter1/04_the_obligatory_hello_world.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                         必修的“Hello World”
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="1.5" data-path="chapter1/05_usecase_and_deployment_scenarios.html">
            
                
                    <a href="../chapter1/05_usecase_and_deployment_scenarios.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                         用例和部署场景
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="1.6" data-path="chapter1/06_examples_of_usecases_for_akka.html">
            
                
                    <a href="../chapter1/06_examples_of_usecases_for_akka.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                         Akka使用实例
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="2" data-path="chapter2/general.html">
            
                
                    <a href="../chapter2/general.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                         概述
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="2.1" data-path="chapter2/01_terminology_concepts.html">
            
                
                    <a href="../chapter2/01_terminology_concepts.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                         术语，概念
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.2" data-path="chapter2/02_actor_systems.html">
            
                
                    <a href="../chapter2/02_actor_systems.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                         Actor系统
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.3" data-path="chapter2/03_what_is_an_actor.html">
            
                
                    <a href="../chapter2/03_what_is_an_actor.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                         什么是Actor?
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.4" data-path="chapter2/04_supervision_and_monitoring.html">
            
                
                    <a href="../chapter2/04_supervision_and_monitoring.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                         监管与监控
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.5" data-path="chapter2/05_actor_references_paths_and_addresses.html">
            
                
                    <a href="../chapter2/05_actor_references_paths_and_addresses.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                         Actor引用, 路径与地址
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.6" data-path="chapter2/06_location_transparency.html">
            
                
                    <a href="../chapter2/06_location_transparency.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                         位置透明性
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.7" data-path="chapter2/07_akka_and_the_java_memory_model.html">
            
                
                    <a href="../chapter2/07_akka_and_the_java_memory_model.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                         Akka与Java内存模型
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.8" data-path="chapter2/08_message_delivery_reliability.html">
            
                
                    <a href="../chapter2/08_message_delivery_reliability.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                         消息发送语义
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="2.9" data-path="chapter2/09_configuration.html">
            
                
                    <a href="../chapter2/09_configuration.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                         配置
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="3" data-path="chapter3/actors.html">
            
                
                    <a href="../chapter3/actors.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                         Actors
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="3.1" data-path="chapter3/01_actors.html">
            
                
                    <a href="../chapter3/01_actors.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                         Actors
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.2" data-path="chapter3/02_typed_actors.html">
            
                
                    <a href="../chapter3/02_typed_actors.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                         有类型Actor
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.3" data-path="chapter3/03_fault_tolerance.html">
            
                
                    <a href="../chapter3/03_fault_tolerance.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                         容错
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="3.3.1" data-path="chapter3/03-1_fault_tolerance_sample.html">
            
                
                    <a href="../chapter3/03-1_fault_tolerance_sample.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.1.</b>
                        
                         容错示例
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="3.4" data-path="chapter3/04_dispatchers.html">
            
                
                    <a href="../chapter3/04_dispatchers.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                         调度器
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.5" data-path="chapter3/05_mailboxes.html">
            
                
                    <a href="../chapter3/05_mailboxes.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                         邮箱
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.6" data-path="chapter3/06_routing.html">
            
                
                    <a href="../chapter3/06_routing.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                         路由
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.7" data-path="chapter3/07_fsm.html">
            
                
                    <a href="../chapter3/07_fsm.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                         有限状态机(FSM)
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.8" data-path="chapter3/08_persistence.html">
            
                
                    <a href="../chapter3/08_persistence.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                         持久化
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="3.9" data-path="chapter3/09_testing_actor_systems.html">
            
                
                    <a href="../chapter3/09_testing_actor_systems.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                         测试Actor系统
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="3.9.1" data-path="chapter3/09_1_testkit-example.html">
            
                
                    <a href="../chapter3/09_1_testkit-example.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.1.</b>
                        
                         TestKit实例
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="3.10" data-path="chapter3/10_actor_dsl.html">
            
                
                    <a href="../chapter3/10_actor_dsl.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                         Actor DSL
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="4" data-path="chapter4/futures_and_agents.html">
            
                
                    <a href="../chapter4/futures_and_agents.html">
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                         Futures与Agents
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="4.1" data-path="chapter4/01_futures.html">
            
                
                    <a href="../chapter4/01_futures.html">
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                         Futures
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="4.2" data-path="chapter4/02_agents.html">
            
                
                    <a href="../chapter4/02_agents.html">
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                         Agents
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="5" data-path="chapter5/networking.html">
            
                
                    <a href="../chapter5/networking.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                         网络
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="5.1" data-path="chapter5/01_cluster_cpecification.html">
            
                
                    <a href="../chapter5/01_cluster_cpecification.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                         集群规格
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.2" data-path="chapter5/02_cluster_usage.html">
            
                
                    <a href="../chapter5/02_cluster_usage.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                         集群用法
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.3" data-path="chapter5/03_remoting.html">
            
                
                    <a href="../chapter5/03_remoting.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                         远程
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.4" data-path="chapter5/04_serialization.html">
            
                
                    <a href="../chapter5/04_serialization.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                         序列化
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.5" data-path="chapter5/05_io.html">
            
                
                    <a href="../chapter5/05_io.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                         I/O
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.6" data-path="chapter5/06_using_tcp.html">
            
                
                    <a href="../chapter5/06_using_tcp.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                         使用TCP
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.7" data-path="chapter5/07_using_udp.html">
            
                
                    <a href="../chapter5/07_using_udp.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                         使用UDP
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter active" data-level="5.8" data-path="chapter5/08_zeromq.html">
            
                
                    <a href="../chapter5/08_zeromq.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                         ZeroMQ
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="5.9" data-path="chapter5/09_camel.html">
            
                
                    <a href="../chapter5/09_camel.html">
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                         Camel
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="6" data-path="chapter6/utilities.html">
            
                
                    <a href="../chapter6/utilities.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                         实用工具
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="6.1" data-path="chapter6/01_event_bus.html">
            
                
                    <a href="../chapter6/01_event_bus.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                         事件总线
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="6.2" data-path="chapter6/02_logging.html">
            
                
                    <a href="../chapter6/02_logging.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                         日志
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="6.3" data-path="chapter6/03_scheduler.html">
            
                
                    <a href="../chapter6/03_scheduler.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                         调度器
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="6.4" data-path="chapter6/04_duration.html">
            
                
                    <a href="../chapter6/04_duration.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                         Duration
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="6.5" data-path="chapter6/05_circuit_breaker.html">
            
                
                    <a href="../chapter6/05_circuit_breaker.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                         线路断路器
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="6.6" data-path="chapter6/06_akka_extensions.html">
            
                
                    <a href="../chapter6/06_akka_extensions.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                         Akka扩展
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="6.7" data-path="chapter6/07_microkernel.html">
            
                
                    <a href="../chapter6/07_microkernel.html">
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                         微内核
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="7" data-path="chapter7/howto_common_patterns.html">
            
                
                    <a href="../chapter7/howto_common_patterns.html">
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                         如何使用：常用模式
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="8" data-path="chapter8/experimental_modules.html">
            
                
                    <a href="../chapter8/experimental_modules.html">
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                         实验模块
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="8.1" data-path="chapter3/08_persistence.html">
            
                
                    <a href="../chapter3/08_persistence.html">
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                         持久化
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="8.2" data-path="chapter8/02_multi_node_testing.html">
            
                
                    <a href="../chapter8/02_multi_node_testing.html">
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                         多节点测试
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="8.3" data-path="chapter8/03_actors.html">
            
                
                    <a href="../chapter8/03_actors.html">
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                         Actors(使用Java的Lambda支持)
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="8.4" data-path="chapter8/04_fsm.html">
            
                
                    <a href="../chapter8/04_fsm.html">
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                         FSM(使用Java的Lambda支持)
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="8.5" data-path="chapter8/05_external_contributions.html">
            
                
                    <a href="../chapter8/05_external_contributions.html">
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                         外部贡献
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="9" data-path="chapter9/information_for_akka_developers.html">
            
                
                    <a href="../chapter9/information_for_akka_developers.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                         Akka开发者信息
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="9.1" data-path="chapter9/01_building_akka.html">
            
                
                    <a href="../chapter9/01_building_akka.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                         构建Akka
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="9.2" data-path="chapter9/02_multi_jvm_testing.html">
            
                
                    <a href="../chapter9/02_multi_jvm_testing.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.2.</b>
                        
                         多JVM测试
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="9.3" data-path="chapter9/03_io_layer_design.html">
            
                
                    <a href="../chapter9/03_io_layer_design.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.3.</b>
                        
                         I/O层设计
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="9.4" data-path="chapter9/04_developer_guidelines.html">
            
                
                    <a href="../chapter9/04_developer_guidelines.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.4.</b>
                        
                         开发指南
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="9.5" data-path="chapter9/05_documentation_guidelines.html">
            
                
                    <a href="../chapter9/05_documentation_guidelines.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.5.</b>
                        
                         文档指南
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="9.6" data-path="chapter9/06_team.html">
            
                
                    <a href="../chapter9/06_team.html">
                        <i class="fa fa-check"></i>
                        
                            <b>9.6.</b>
                        
                         团队
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="10" data-path="chapter10/project_information.html">
            
                
                    <a href="../chapter10/project_information.html">
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                         工程信息
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="10.1" data-path="chapter10/01_migration_guides.html">
            
                
                    <a href="../chapter10/01_migration_guides.html">
                        <i class="fa fa-check"></i>
                        
                            <b>10.1.</b>
                        
                         迁移指南
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="10.2" data-path="chapter10/02_issue_tracking.html">
            
                
                    <a href="../chapter10/02_issue_tracking.html">
                        <i class="fa fa-check"></i>
                        
                            <b>10.2.</b>
                        
                         问题追踪
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="10.3" data-path="chapter10/03_licenses.html">
            
                
                    <a href="../chapter10/03_licenses.html">
                        <i class="fa fa-check"></i>
                        
                            <b>10.3.</b>
                        
                         许可证
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="10.4" data-path="chapter10/04_sponsors.html">
            
                
                    <a href="../chapter10/04_sponsors.html">
                        <i class="fa fa-check"></i>
                        
                            <b>10.4.</b>
                        
                         赞助商
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="10.5" data-path="chapter10/05_project.html">
            
                
                    <a href="../chapter10/05_project.html">
                        <i class="fa fa-check"></i>
                        
                            <b>10.5.</b>
                        
                         项目
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        
        <li class="chapter " data-level="11" data-path="chapter11/additional_information.html">
            
                
                    <a href="../chapter11/additional_information.html">
                        <i class="fa fa-check"></i>
                        
                            <b>11.</b>
                        
                         附加信息
                    </a>
                
            
            
            <ul class="articles">
                
    
        
        <li class="chapter " data-level="11.1" data-path="chapter11/01_faq.html">
            
                
                    <a href="../chapter11/01_faq.html">
                        <i class="fa fa-check"></i>
                        
                            <b>11.1.</b>
                        
                         常见问题
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="11.2" data-path="chapter11/02_books.html">
            
                
                    <a href="../chapter11/02_books.html">
                        <i class="fa fa-check"></i>
                        
                            <b>11.2.</b>
                        
                         图书
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="11.3" data-path="chapter11/03_other_language_bindings.html">
            
                
                    <a href="../chapter11/03_other_language_bindings.html">
                        <i class="fa fa-check"></i>
                        
                            <b>11.3.</b>
                        
                         其他语言绑定
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="11.4" data-path="chapter11/04_akka_in_osgi.html">
            
                
                    <a href="../chapter11/04_akka_in_osgi.html">
                        <i class="fa fa-check"></i>
                        
                            <b>11.4.</b>
                        
                         Akka与OSGi
                    </a>
                
            
            
        </li>
    
        
        <li class="chapter " data-level="11.5" data-path="chapter11/05_incomplete_list_of_http_frameworks.html">
            
                
                    <a href="../chapter11/05_incomplete_list_of_http_frameworks.html">
                        <i class="fa fa-check"></i>
                        
                            <b>11.5.</b>
                        
                         部分HTTP框架名单
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    


        
        <li class="divider"></li>
        <li>
            <a href="http://www.gitbook.io/" target="blank" class="gitbook-link">Published using GitBook</a>
        </li>
        
    </ul>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="Toggle search"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="Toggle font settings"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">Serif</button>
        <button type="button" data-font="1" class="button">Sans</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">White</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">Sepia</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">Night</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="Toggle share dropdown"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">Twitter</button>
                <button type="button" data-sharing="google-plus" class="button">Google</button>
                <button type="button" data-sharing="facebook" class="button">Facebook</button>
                <button type="button" data-sharing="weibo" class="button">Weibo</button>
                <button type="button" data-sharing="instapaper" class="button">Instapaper</button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Share on Google Plus"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Share on Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Share on Twitter"><i class="fa fa-twitter"></i></a>
    
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >AKKA 2.3.6 Scala 文档</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-gitbook_133">
                    
                        <h1 id="zeromq">ZeroMQ</h1>
<blockquote>
<p>注： 直接从Akka 2.0文档中复制，没有仔细检查</p>
</blockquote>
<p>Akka提供一个 ZeroMQ 模块对 ZeroMQ 连接进行抽象从而允许Akka actor之间在ZeroMQ连接之上进行消息交互。这些消息可以是专有格式或者使用Protobuf来定义。socket actor缺省就具有容错性，当你调用newSocket方法创建新的Socket时它会恰当地对socket进行重新初始化。</p>
<p>ZeroMQ 在多线程方面有较大的强制性，所以配置选项 <code>akka.zeromq.socket-dispatcher</code> 一定要设置成 PinnedDispatcher, 这是因为实际的ZeroMQ socket只能在创建它的线程中访问。</p>
<p>Akka的ZeroMQ模块是按照JZMQ中的API编写的，JZMQ使用JNI与本地ZeroMQ库通信，但Akka ZeroMQ模块没有用JZMQ，用的是ZeroMQ的Scala绑定，与本地ZeroMQ库通信是通过JNA完成的. 换句话说，这个模块所需要的本地库只有本地 ZeroMQ 库. 使用scala库的好处是你不需要编译和管理本地的信赖，当然这会有一些性能上的损失。Scala绑定与JNI绑定是兼容的，如果你的确需要获得最好的性能，直接用后者替换前者即可。</p>
<blockquote>
<p>注意</p>
<p><code>zeromq-scala-bindings</code>当前所用的版本只兼容 zeromq 2 ；zeromq 3 不受支持。</p>
</blockquote>
<h3 id="">连接</h3>
<p>ZeroMQ 支持多种连接模式, 每一种用来满足不同的需求。 目前这个模块支持发布－订阅型连接和基于Router－Dealer的连接. 为了发起连接或接收连接，必须创建一个socket. Socket都是用 akka.zeromq.ZeroMQExtension创建的, 例如:</p>
<pre><code class="lang-scala"><span class="hljs-keyword">import</span> akka.zeromq.<span class="hljs-type">ZeroMQExtension</span>
<span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">pubSocket</span> =</span> <span class="hljs-type">ZeroMQExtension</span>(system).newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Pub</span>,
  <span class="hljs-type">Bind</span>(<span class="hljs-string">"tcp://127.0.0.1:21231"</span>))
</code></pre>
<p>或者通过导入 akka.zeromq._ 包来获得隐式的newSocket方法.</p>
<pre><code class="lang-scala"><span class="hljs-keyword">import</span> akka.zeromq._
<span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">pubSocket2</span> =</span> system.newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Pub</span>, <span class="hljs-type">Bind</span>(<span class="hljs-string">"tcp://127.0.0.1:1234"</span>))
</code></pre>
<p>上例将在本机的1234端口创建一个ZeroMQ发布者socket。.</p>
<p>类似的你可以创建一个带有监听器的订阅socket, 从发布者订阅所有的消息:</p>
<pre><code class="lang-scala"><span class="hljs-keyword">import</span> akka.zeromq._
<span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">listener</span> =</span> system.actorOf(<span class="hljs-type">Props</span>(<span class="hljs-keyword">new</span> <span class="hljs-type">Actor</span> {
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">receive</span>:</span> <span class="hljs-type">Receive</span> = {
    <span class="hljs-keyword">case</span> <span class="hljs-type">Connecting</span>    ⇒ <span class="hljs-comment">//...</span>
    <span class="hljs-keyword">case</span> m: <span class="hljs-type">ZMQMessage</span> ⇒ <span class="hljs-comment">//...</span>
    <span class="hljs-keyword">case</span> _             ⇒ <span class="hljs-comment">//...</span>
  }
}))
<span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">subSocket</span> =</span> system.newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Sub</span>, <span class="hljs-type">Listener</span>(listener), <span class="hljs-type">Connect</span>(<span class="hljs-string">"tcp://127.0.0.1:1234"</span>), <span class="hljs-type">SubscribeAll</span>)
</code></pre>
<p>下面的章节将描述所支持的连接方式以及它们在Akka环境中的用法。但是，如果要详细了解各种连接方式，请参阅 ZeroMQ – The Guide.</p>
<h5 id="-">发布-订阅型连接</h5>
<p>在一个发布-订阅(pub-sub)型连接中, 一个发布者可以有多个订阅者. 每个订阅者订阅一个或多个主题 , 发布者向主题发布消息. 订阅者也可以订阅所有的主题. 在 Akka 环境中, 如果要向并不直接与某actor打交道的actor发布消息，需要使用pub-sub 连接.</p>
<p>在使用 zeromq pub/sub 时你必须知道它需要多播 - 检查你的云环境 - 才能正确工作，同时对事件主题的过滤发生在客户端, 因此所有的事件都会广播到所有的订阅者.</p>
<p>actor订阅主题的过程如下:</p>
<pre><code class="lang-scala"><span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">subTopicSocket</span> =</span> system.newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Sub</span>, <span class="hljs-type">Listener</span>(listener), <span class="hljs-type">Connect</span>(<span class="hljs-string">"tcp://127.0.0.1:1234"</span>), <span class="hljs-type">Subscribe</span>(<span class="hljs-string">"foo.bar"</span>))
</code></pre>
<p>订阅时使用前缀匹配，所以它订阅了所有以 foo.bar 开头的主题. 注意，如果没有提供主题名称或使用了 SubscribeAll , actor 将订阅所有的主题.</p>
<p>要取消订阅:</p>
<pre><code class="lang-scala">subTopicSocket ! <span class="hljs-type">Unsubscribe</span>(<span class="hljs-string">"foo.bar"</span>)
</code></pre>
<p>要向主题发布消息你必须使用两个 Frames，第一个Frame是主题.</p>
<pre><code class="lang-scala">pubSocket ! <span class="hljs-type">ZMQMessage</span>(<span class="hljs-type">Seq</span>(<span class="hljs-type">Frame</span>(<span class="hljs-string">"foo.bar"</span>), <span class="hljs-type">Frame</span>(payload)))
</code></pre>
<h5 id="pub-sub">Pub-Sub实战</h5>
<p>下例演示了一个有两个订阅者的发布者.</p>
<p>发布者监视当前的堆使用量和系统负载并周期性在&quot;health.heap&quot; 主题上发布 Heap 事件， 在&quot;health.load&quot;主题上发布 Load 事件.</p>
<pre><code class="lang-scala"><span class="hljs-keyword">import</span> akka.zeromq._
<span class="hljs-keyword">import</span> akka.actor.<span class="hljs-type">Actor</span>
<span class="hljs-keyword">import</span> akka.actor.<span class="hljs-type">Props</span>
<span class="hljs-keyword">import</span> akka.actor.<span class="hljs-type">ActorLogging</span>
<span class="hljs-keyword">import</span> akka.serialization.<span class="hljs-type">SerializationExtension</span>
<span class="hljs-keyword">import</span> java.lang.management.<span class="hljs-type">ManagementFactory</span>

<span class="hljs-keyword">case</span> <span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-title">Tick</span>
</span><span class="hljs-keyword">case</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Heap</span>(</span>timestamp: <span class="hljs-type">Long</span>, used: <span class="hljs-type">Long</span>, max: <span class="hljs-type">Long</span>)
<span class="hljs-keyword">case</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Load</span>(</span>timestamp: <span class="hljs-type">Long</span>, loadAverage: <span class="hljs-type">Double</span>)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HealthProbe</span> <span class="hljs-keyword"><span class="hljs-keyword">extends</span></span> <span class="hljs-title">Actor</span> {</span>

  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">pubSocket</span> =</span> context.system.newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Pub</span>, <span class="hljs-type">Bind</span>(<span class="hljs-string">"tcp://127.0.0.1:1235"</span>))
  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">memory</span> =</span> <span class="hljs-type">ManagementFactory</span>.getMemoryMXBean
  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">os</span> =</span> <span class="hljs-type">ManagementFactory</span>.getOperatingSystemMXBean
  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">ser</span> =</span> <span class="hljs-type">SerializationExtension</span>(context.system)

  <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">preStart</span>(</span>) {
    context.system.scheduler.schedule(<span class="hljs-number">1</span> second, <span class="hljs-number">1</span> second, self, <span class="hljs-type">Tick</span>)
  }

  <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">postRestart</span>(</span>reason: <span class="hljs-type">Throwable</span>) {
    <span class="hljs-comment">// 还要调用preStart，仅调度一次</span>
  }

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">receive</span>:</span> <span class="hljs-type">Receive</span> = {
    <span class="hljs-keyword">case</span> <span class="hljs-type">Tick</span> ⇒
      <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">currentHeap</span> =</span> memory.getHeapMemoryUsage
      <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">timestamp</span> =</span> <span class="hljs-type">System</span>.currentTimeMillis

      <span class="hljs-comment">// 用 akka SerializationExtension 转换成字节</span>
      <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">heapPayload</span> =</span> ser.serialize(<span class="hljs-type">Heap</span>(timestamp, currentHeap.getUsed, currentHeap.getMax)).fold(<span class="hljs-keyword">throw</span> _, identity)
      <span class="hljs-comment">// 第一Frame是话题，第二Frame是消息</span>
      pubSocket ! <span class="hljs-type">ZMQMessage</span>(<span class="hljs-type">Seq</span>(<span class="hljs-type">Frame</span>(<span class="hljs-string">"health.heap"</span>), <span class="hljs-type">Frame</span>(heapPayload)))

      <span class="hljs-comment">// 用 akka SerializationExtension 转换成字节</span>
      <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">loadPayload</span> =</span> ser.serialize(<span class="hljs-type">Load</span>(timestamp, os.getSystemLoadAverage)).fold(<span class="hljs-keyword">throw</span> _, identity)
      <span class="hljs-comment">// 第一Frame是主题，第二Frame是消息</span>
      pubSocket ! <span class="hljs-type">ZMQMessage</span>(<span class="hljs-type">Seq</span>(<span class="hljs-type">Frame</span>(<span class="hljs-string">"health.load"</span>), <span class="hljs-type">Frame</span>(loadPayload)))
  }
}

  system.actorOf(<span class="hljs-type">Props</span>[<span class="hljs-type">HealthProbe</span>], name = <span class="hljs-string">"health"</span>)
</code></pre>
<p>我们添加一个订阅者来记录日志. 它订阅所有以 &quot;health&quot;开头的主题, i.e. 包括 Heap 和 Load 事件.</p>
<pre><code class="lang-scala"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Logger</span> <span class="hljs-keyword"><span class="hljs-keyword">extends</span></span> <span class="hljs-title">Actor</span> <span class="hljs-keyword"><span class="hljs-keyword">with</span></span> <span class="hljs-title">ActorLogging</span> {</span>

  context.system.newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Sub</span>, <span class="hljs-type">Listener</span>(self), <span class="hljs-type">Connect</span>(<span class="hljs-string">"tcp://127.0.0.1:1235"</span>), <span class="hljs-type">Subscribe</span>(<span class="hljs-string">"health"</span>))
  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">ser</span> =</span> <span class="hljs-type">SerializationExtension</span>(context.system)
  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">timestampFormat</span> =</span> <span class="hljs-keyword">new</span> <span class="hljs-type">SimpleDateFormat</span>(<span class="hljs-string">"HH:mm:ss.SSS"</span>)

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">receive</span> =</span> {
    <span class="hljs-comment">// 第一Frame是主题，第二Frame是消息</span>
    <span class="hljs-keyword">case</span> m: <span class="hljs-type">ZMQMessage</span> <span class="hljs-keyword">if</span> m.firstFrameAsString == <span class="hljs-string">"health.heap"</span> ⇒
      ser.deserialize(m.payload(<span class="hljs-number">1</span>), classOf[<span class="hljs-type">Heap</span>]) <span class="hljs-keyword">match</span> {
        <span class="hljs-keyword">case</span> <span class="hljs-type">Right</span>(<span class="hljs-type">Heap</span>(timestamp, used, max)) ⇒
          log.info(<span class="hljs-string">"Used heap {} bytes, at {}"</span>, used, timestampFormat.format(<span class="hljs-keyword">new</span> <span class="hljs-type">Date</span>(timestamp)))
        <span class="hljs-keyword">case</span> <span class="hljs-type">Left</span>(e) ⇒ <span class="hljs-keyword">throw</span> e
      }

    <span class="hljs-keyword">case</span> m: <span class="hljs-type">ZMQMessage</span> <span class="hljs-keyword">if</span> m.firstFrameAsString == <span class="hljs-string">"health.load"</span> ⇒
      ser.deserialize(m.payload(<span class="hljs-number">1</span>), classOf[<span class="hljs-type">Load</span>]) <span class="hljs-keyword">match</span> {
        <span class="hljs-keyword">case</span> <span class="hljs-type">Right</span>(<span class="hljs-type">Load</span>(timestamp, loadAverage)) ⇒
          log.info(<span class="hljs-string">"Load average {}, at {}"</span>, loadAverage, timestampFormat.format(<span class="hljs-keyword">new</span> <span class="hljs-type">Date</span>(timestamp)))
        <span class="hljs-keyword">case</span> <span class="hljs-type">Left</span>(e) ⇒ <span class="hljs-keyword">throw</span> e
      }
  }
}

  system.actorOf(<span class="hljs-type">Props</span>[<span class="hljs-type">Logger</span>], name = <span class="hljs-string">"logger"</span>)
</code></pre>
<p>另一个订阅者了解堆内存用量，如果堆使用过量则提出警告. 它仅订阅 Heap 事件.</p>
<pre><code class="lang-scala"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HeapAlerter</span> <span class="hljs-keyword"><span class="hljs-keyword">extends</span></span> <span class="hljs-title">Actor</span> <span class="hljs-keyword"><span class="hljs-keyword">with</span></span> <span class="hljs-title">ActorLogging</span> {</span>

  context.system.newSocket(<span class="hljs-type">SocketType</span>.<span class="hljs-type">Sub</span>, <span class="hljs-type">Listener</span>(self), <span class="hljs-type">Connect</span>(<span class="hljs-string">"tcp://127.0.0.1:1235"</span>), <span class="hljs-type">Subscribe</span>(<span class="hljs-string">"health.heap"</span>))
  <span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">ser</span> =</span> <span class="hljs-type">SerializationExtension</span>(context.system)
  <span class="hljs-keyword">var</span> count = <span class="hljs-number">0</span>

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">receive</span> =</span> {
    <span class="hljs-comment">// 第一Frame是主题，第二Frame是消息</span>
    <span class="hljs-keyword">case</span> m: <span class="hljs-type">ZMQMessage</span> <span class="hljs-keyword">if</span> m.firstFrameAsString == <span class="hljs-string">"health.heap"</span> ⇒
      ser.deserialize(m.payload(<span class="hljs-number">1</span>), classOf[<span class="hljs-type">Heap</span>]) <span class="hljs-keyword">match</span> {
        <span class="hljs-keyword">case</span> <span class="hljs-type">Right</span>(<span class="hljs-type">Heap</span>(timestamp, used, max)) ⇒
          <span class="hljs-keyword">if</span> ((used.toDouble / max) &gt; <span class="hljs-number">0.9</span>) count += <span class="hljs-number">1</span>
          <span class="hljs-keyword">else</span> count = <span class="hljs-number">0</span>
          <span class="hljs-keyword">if</span> (count &gt; <span class="hljs-number">10</span>) log.warning(<span class="hljs-string">"Need more memory, using {} %"</span>, (<span class="hljs-number">100.0</span> * used / max))
        <span class="hljs-keyword">case</span> <span class="hljs-type">Left</span>(e) ⇒ <span class="hljs-keyword">throw</span> e
      }
  }
}

  system.actorOf(<span class="hljs-type">Props</span>[<span class="hljs-type">HeapAlerter</span>], name = <span class="hljs-string">"alerter"</span>)
</code></pre>
<h5 id="router-dealer-connection">Router-Dealer Connection</h5>
<p>虽然 Pub/Sub 是很好的连接方式但zeromq的真正优势在于它象一个用于可靠消息通信的 “乐高玩具” . 而由于有如此多的集成方式，它的多语言支持是极好的. 当你使用ZeroMQ来集成多个系统时你可能需要创建自己的ZeroMQ机制。这时就轮到router 和 dealer socket 类型发挥作用了. 使用这些socket类型你可以创建自己的使用TCP/IP的可靠pub sub broker，并实现发布方的事件过滤.</p>
<p>要创建配置了高水位的Router socket:</p>
<pre><code class="lang-scala"><span class="hljs-function"><span class="hljs-keyword">val</span> <span class="hljs-title">highWatermarkSocket</span> =</span> system.newSocket(
  <span class="hljs-type">SocketType</span>.<span class="hljs-type">Router</span>,
  <span class="hljs-type">Listener</span>(listener),
  <span class="hljs-type">Bind</span>(<span class="hljs-string">"tcp://127.0.0.1:1234"</span>),
  <span class="hljs-type">HighWatermark</span>(<span class="hljs-number">50000</span>))
</code></pre>
<p>akka-zeromq 模块支持大部分zeromq socket的配置选项.</p>
<h5 id="">推－拉型连接</h5>
<p>Akka ZeroMQ 模块支持 推-拉 型连接.</p>
<p>创建 Push 连接:</p>
<pre><code class="lang-scala"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">newPushSocket</span>(</span>socketParameters: <span class="hljs-type">Array</span>[<span class="hljs-type">SocketOption</span>]): <span class="hljs-type">ActorRef</span>
</code></pre>
<p>创建 Pull 型连接:</p>
<pre><code class="lang-scala"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">newPullSocket</span>(</span>socketParameters: <span class="hljs-type">Array</span>[<span class="hljs-type">SocketOption</span>]): <span class="hljs-type">ActorRef</span>
</code></pre>
<p>很快将提供有更多的文档和示例.</p>
<h5 id="">请求－响应型连接</h5>
<p>Akka ZeroMQ 模块支持 请求-响应 型连接.</p>
<p>创建 响应 连接:</p>
<pre><code class="lang-scala"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">newReqSocket</span>(</span>socketParameters: <span class="hljs-type">Array</span>[<span class="hljs-type">SocketOption</span>]): <span class="hljs-type">ActorRef</span>
</code></pre>
<p>创建 请求 连接:</p>
<pre><code class="lang-scala"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">newRepSocket</span>(</span>socketParameters: <span class="hljs-type">Array</span>[<span class="hljs-type">SocketOption</span>]): <span class="hljs-type">ActorRef</span>
</code></pre>
<p>很快将提供更多的文档和示例.</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../chapter5/07_using_udp.html" class="navigation navigation-prev " aria-label="Previous page: 使用UDP"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../chapter5/09_camel.html" class="navigation navigation-next " aria-label="Next page: Camel"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="https://cdn.mathjax.org/mathjax/2.4-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-mathjax/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
